//
//  WWDoctorHeaderView.m
//  快医
//
//  Created by 张湾湾 on 16/7/7.
//
//

#import "WWDoctorHeaderView.h"

#import "UIImage+ProfileImage.h"

#import "WWMarginButton.h"

@interface WWDoctorHeaderView()
/**头像*/
@property (nonatomic,weak)UIImageView *iconImageView;
/**姓名*/
@property (nonatomic,weak)UILabel *nameLabel;
/**级别*/
@property (nonatomic,weak)UILabel *honorLabel;
/**所属医院*/
@property (nonatomic,weak)UILabel *hospitalLabel;

// 放置3个button 的view
@property (nonatomic,weak)UIView *tempView;

/**添加按钮*/
@property (nonatomic,weak)WWMarginButton *addButton;
/**鲜花*/
@property (nonatomic,weak)WWMarginButton *flowerButton;
/**收藏*/
@property (nonatomic,weak)WWMarginButton *collectionButton;


@end

@implementation WWDoctorHeaderView


- (void)setHeaderModel:(WWPayAttentionModel *)headerModel{

    _headerModel = headerModel;

    //传值
    [self.iconImageView setProfileImageWithImageURLPath:self.headerModel.doctor_portrait];
    
    self.nameLabel.text = headerModel.doctor_name;
    self.honorLabel.text =  headerModel.doctor_title_name;
    self.hospitalLabel.text = headerModel.doctor_hospital_name;
    [self.addButton setTitle:headerModel.flower forState:UIControlStateNormal];
    [self.addButton setTitle:headerModel.operation_count forState:UIControlStateNormal];
    [self.collectionButton setTitle:headerModel.banner forState:UIControlStateNormal];
    
}


- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        //MARK: - 初始化控件
        [self setupUI];
       
        //MARK: - 约束设置
        [self setupConstrains];
    }
    return self;
    
}

- (void)setupUI{
    
    //MARK: - 头像
    UIImageView * iconImageView = [[UIImageView alloc]init];
    self.iconImageView = iconImageView;
    self.iconImageView.image = [UIImage imageNamed:@"illness_img_person.png"];
    [self  addSubview:iconImageView];
    
    //MARK: - 姓名
    UILabel * nameLabel = [[UILabel alloc]init];
    self.nameLabel = nameLabel;
    self.nameLabel.text = @"马医生";
    self.nameLabel.textColor = [UIColor blackColor];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
    
    [self  addSubview:nameLabel];
    
    //MARK: - 级别
    UILabel * honorLabel = [[UILabel alloc]init];
    self.honorLabel = honorLabel;
    self.honorLabel.textColor = [UIColor grayColor];
    self.honorLabel.font = [UIFont systemFontOfSize:13];
    self.honorLabel.text = @"主治医生";
    
    [self addSubview:honorLabel];
    
    //MARK: - 医院
    UILabel * hosptilLabel = [[UILabel alloc]init];
    self.hospitalLabel = hosptilLabel;
    self.hospitalLabel.textColor = [UIColor grayColor];
    self.hospitalLabel.font = [UIFont systemFontOfSize:13];
    self.hospitalLabel.text = @"医院名字";
    
    [self addSubview:hosptilLabel];
    
    //MARK: - 临时防止三个button的view
    UIView * tempView = [[UIView alloc]init];
    self.tempView = tempView;
//    self.tempView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:tempView]
    ;
    //MARK: - 加
    WWMarginButton * addButton = [[WWMarginButton alloc]init];
    self.addButton = addButton;
    [self.addButton setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
    [self.addButton setTitle:@"11" forState:UIControlStateNormal];
    [self.addButton setTitleColor:XHRColorWithRGB(119, 210, 210) forState:UIControlStateNormal];
    self.addButton.titleLabel.font  = [UIFont systemFontOfSize:12];
    
    [self.tempView addSubview:addButton];
    
    //MARK: - 鲜花
    WWMarginButton * flowerButton = [[WWMarginButton alloc]init];
    self.flowerButton = flowerButton;
    [self.flowerButton setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
    [self.flowerButton setTitle:@"11" forState:UIControlStateNormal];
    [self.flowerButton setTitleColor:XHRColorWithRGB(119, 210, 210) forState:UIControlStateNormal];
    self.flowerButton.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [self.tempView addSubview:flowerButton];
    
    //MARK: - 收藏
    WWMarginButton * attentionButton = [[WWMarginButton alloc]init];
    self.collectionButton = attentionButton;
    [self.collectionButton setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
    [self.collectionButton setTitle:@"11" forState:UIControlStateNormal];
    [self.collectionButton setTitleColor:XHRColorWithRGB(119, 210, 210) forState:UIControlStateNormal];
    self.collectionButton.titleLabel.font  = [UIFont systemFontOfSize:12];
    
    [self.tempView addSubview:attentionButton];
   
    
}


#pragma mark
#pragma mark - 布局位置,设置约束
- (void)setupConstrains{
    //MARK: - 头像约束
    [self.iconImageView makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(20);
        make.centerY.equalTo(self);
        make.width.height.equalTo(90);
    }];
    
    //MARK: - 姓名
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView.top).offset(5);
        make.leading.equalTo(self.iconImageView.trailing).offset(5);
    }];
    
    //MARK: - 级别
    [self.honorLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.top);
        make.leading.equalTo(self.nameLabel.trailing).offset(15);
    }];
    
    //MARK: - 医院
    [self.hospitalLabel makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel.leading);
        make.top.equalTo(self.nameLabel.bottom).offset(10);
        make.width.equalTo(100);
        
        
    }];
    
    //MARK: - 临时的view
    [self.tempView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView.bottom).offset(5);
        make.leading.equalTo(self.iconImageView.leading).offset(10);
        make.height.equalTo(30);
        make.width.equalTo(XHRScreenSize);
        
    }];
    
    //MARK: - 添加
    [self.addButton makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(0);
        make.centerY.equalTo(self.tempView);
        make.width.equalTo(50);
        
    }];
    
    //MARK: - 鲜花
    [self.flowerButton makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.tempView);
        make.leading.equalTo(self.addButton.trailing).offset(30);
        make.width.equalTo(50);
    }];
    
    //MARK: - 收藏
    [self.collectionButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.tempView);
        make.leading.equalTo(self.flowerButton.trailing).offset(30);
        make.width.equalTo(50);
    }];
    
}





@end
